package star.搜索与回溯.对称二叉树;

public class IsSymmetric {
    public boolean isSymmetric(TreeNode root) {
        if (root==null) return true;
        return isTrue(root.left,root.right);
    }

    public boolean isTrue(TreeNode left,TreeNode right){
        if (left==null & right==null) return true;
        if ((left!=null & right==null) || (left==null & right!=null) || left.val != right.val) return false;
        return isTrue(left.left,right.right) && isTrue(left.right,right.left);
    }
}
